package com.jilijili.pojo.vo;


import com.jilijili.pojo.Comment;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;
import org.springframework.util.ObjectUtils;

import java.time.LocalDateTime;

/**
 * @BelongsProject: jilijili-red-book-dev
 * @BelongsPackage: com.jilijili.pojo.vo
 * @Author: ljj
 * @CreateTime: 2022-04-04  07:32
 * @Description: TODO
 * @Version: 1.0
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Accessors(chain = true)
@Builder
public class CommentVo {
    private String id;
    private String commentId;
    private String vlogerId;
    private String fatherCommentId;
    private String vlogId;
    private String commentUserId;
    private String commentUserNickname;
    private String commentUserFace;
    private String content;
    private Integer likeCounts;
    private String replyedUserNickname;
    private LocalDateTime createTime;
    @Builder.Default
    private Integer isLike = 0;


    public static CommentVo convertCommentVo(final Comment comment) {
        CommentVo commentVo = new CommentVo();
        if (!ObjectUtils.isEmpty(comment)) {
            BeanUtils.copyProperties(comment, commentVo);
        }
        return commentVo;

    }

    public static Comment convertComment(final CommentVo commentVo) {
        Comment comment = new Comment();
        if (!ObjectUtils.isEmpty(commentVo)) {
            BeanUtils.copyProperties(commentVo, comment);
        }
        return comment;
    }
}
